package ui.component
{
	import flash.filters.BitmapFilterQuality;
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	import flash.text.TextFormat;

	/**
	 * 自定义的TextField
	 * @author luguobin
	 */
	public class GameTextField extends TextField
	{
		public static var glowFilter:GlowFilter = new GlowFilter(0x000000, 1, 2, 2, 150, BitmapFilterQuality.LOW);

		public function GameTextField(selectEnabled:Boolean = false)
		{
			super();
			mouseWheelEnabled = false;
			selectable = selectEnabled;
			mouseEnabled = selectEnabled;
			//filters = [glowFilter];
		}

		/**
		 * 文字是否有边框
		 */
		public function set isGlowFilter(value:Boolean):void
		{
			filters = value ? [glowFilter] : [];
		}

		/**
		 * 设置mytext时，同时设置了width和height，主要是起到TextField.autoSize = TextFieldAutoSize.LEFT;的作用
		 */
		public function set mytext(value:String):void
		{
			text = value;
			width = textWidth + 4;
			height = textHeight + 4;
		}

		public function set myHtmlText(value:String):void
		{
			wordWrap = multiline = true;
			htmlText = value;
			height = textHeight + 4;
		}
		private static var myTextFormat:TextFormat = new TextFormat("tahoma");

		public static function getTextFormat(color:uint = 0xFFFFFF, size:int = 12, bold:Boolean = false, align:String = "left", leading:int = 4):TextFormat
		{
			myTextFormat.color = color;
			myTextFormat.size = size;
			myTextFormat.bold = bold;
			myTextFormat.leading = leading;
			myTextFormat.align = align;
			return myTextFormat;
		}
	}
}